package com.rzy.l_volatile.a;

/**
 * @author gao
 * @time 2021/05/23 21:59:03
 * 该例子搭配图： 5.happens-before关系.jpg
 */
public class App3 {
    int a = 0;
    volatile boolean flag = false;

    public void writer() {
        a = 1;                  // 1
        flag = true;            // 2
    }

    public void reader() {
        if (flag) {             // 3
            int i = a;          // 4
        }
    }
}
